home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / caps / nsICryptoHash.h next >
C/C++ Source or Header  |  2006-05-08  |  8KB  |  229 lines

  1. /*
  2.  * DO NOT EDIT.  THIS FILE IS GENERATED FROM nsICryptoHash.idl
  3.  */
  4.  
  5. #ifndef __gen_nsICryptoHash_h__
  6. #define __gen_nsICryptoHash_h__
  7.  
  8.  
  9. #ifndef __gen_nsISupports_h__
  10. #include "nsISupports.h"
  11. #endif
  12.  
  13. /* For IDL files that don't want to include root IDL files. */
  14. #ifndef NS_NO_VTABLE
  15. #define NS_NO_VTABLE
  16. #endif
  17. class nsIInputStream; /* forward declaration */
  18.  
  19.  
  20. /* starting interface:    nsICryptoHash */
  21. #define NS_ICRYPTOHASH_IID_STR "1e5b7c43-4688-45ce-92e1-77ed931e3bbe"
  22.  
  23. #define NS_ICRYPTOHASH_IID \
  24.   {0x1e5b7c43, 0x4688, 0x45ce, \
  25.     { 0x92, 0xe1, 0x77, 0xed, 0x93, 0x1e, 0x3b, 0xbe }}
  26.  
  27. /**
  28.  * nsICryptoHash
  29.  * This interface provides crytographic hashing algorithms.
  30.  */
  31. class NS_NO_VTABLE nsICryptoHash : public nsISupports {
  32.  public: 
  33.  
  34.   NS_DEFINE_STATIC_IID_ACCESSOR(NS_ICRYPTOHASH_IID)
  35.  
  36.   /**
  37.      * Hashing Algorithms.  These values are to be used by the
  38.      * |init| method to indicate which hashing function to
  39.      * use.  These values map directly onto the values defined
  40.      * in mozilla/security/nss/lib/cryptohi/hasht.h.
  41.      */
  42.   enum { MD2 = 1 };
  43.  
  44.   enum { MD5 = 2 };
  45.  
  46.   enum { SHA1 = 3 };
  47.  
  48.   enum { SHA256 = 4 };
  49.  
  50.   enum { SHA384 = 5 };
  51.  
  52.   enum { SHA512 = 6 };
  53.  
  54.   /**
  55.      * Initialize the hashing object. This method may be
  56.      * called multiple times with different algorithm types.
  57.      *
  58.      * @param aAlgorithm the algorithm type to be used.
  59.      *        This value must be one of the above valid
  60.      *        algorithm types.
  61.      *
  62.      * @throws NS_ERROR_INVALID_ARG if an unsupported algorithm
  63.      *         type is passed.
  64.      *
  65.      * NOTE: This method or initWithString must be called
  66.      *       before any other method on this interface is called.
  67.      */
  68.   /* void init (in unsigned long aAlgorithm); */
  69.   NS_IMETHOD Init(PRUint32 aAlgorithm) = 0;
  70.  
  71.   /**
  72.      * Initialize the hashing object. This method may be
  73.      * called multiple times with different algorithm types.
  74.      *
  75.      * @param aAlgorithm the algorithm type to be used.
  76.      *
  77.      * @throws NS_ERROR_INVALID_ARG if an unsupported algorithm
  78.      *         type is passed.
  79.      *
  80.      * NOTE: This method or init must be called before any
  81.      *       other method on this interface is called.
  82.      */
  83.   /* void initWithString (in ACString aAlgorithm); */
  84.   NS_IMETHOD InitWithString(const nsACString & aAlgorithm) = 0;
  85.  
  86.   /**
  87.      * @param aData a buffer to calculate the hash over
  88.      *
  89.      * @param aLen the length of the buffer |aData|
  90.      *
  91.      * @throws NS_ERROR_NOT_INITIALIZED if |init| has not been 
  92.      *         called.
  93.      */
  94.   /* void update ([array, size_is (aLen), const] in octet aData, in unsigned long aLen); */
  95.   NS_IMETHOD Update(const PRUint8 *aData, PRUint32 aLen) = 0;
  96.  
  97.   /**
  98.      * Calculates and updates a new hash based on a given data stream.
  99.      *
  100.      * @param aStream an input stream to read from.
  101.      *
  102.      * @param aLen how much to read from the given |aStream|.  Passing
  103.      *        PR_UINT32_MAX indicates that all data available will be used 
  104.      *        to update the hash. 
  105.      *
  106.      * @throws NS_ERROR_NOT_INITIALIZED if |init| has not been 
  107.      *         called.
  108.      *
  109.      * @throws NS_ERROR_NOT_AVAILABLE if the requested amount of 
  110.      *         data to be calculated into the hash is not available.
  111.      *
  112.      */
  113.   /* void updateFromStream (in nsIInputStream aStream, in unsigned long aLen); */
  114.   NS_IMETHOD UpdateFromStream(nsIInputStream *aStream, PRUint32 aLen) = 0;
  115.  
  116.   /**
  117.      * Completes this hash object and produces the actual hash data.
  118.      *
  119.      * @param aASCII if true then the returned value is a base-64 
  120.      *        encoded string.  if false, then the returned value is
  121.      *        binary data.  
  122.      *
  123.      * @return a hash of the data that was read by this object.  This can
  124.      *         be either binary data or base 64 encoded.
  125.      *
  126.      * @throws NS_ERROR_NOT_INITIALIZED if |init| has not been 
  127.      *         called.
  128.      *
  129.      * NOTE: This method may be called any time after |init|
  130.      *       is called.  This call resets the object to its
  131.      *       pre-init state.
  132.      */
  133.   /* ACString finish (in PRBool aASCII); */
  134.   NS_IMETHOD Finish(PRBool aASCII, nsACString & _retval) = 0;
  135.  
  136. };
  137.  
  138. /* Use this macro when declaring classes that implement this interface. */
  139. #define NS_DECL_NSICRYPTOHASH \
  140.   NS_IMETHOD Init(PRUint32 aAlgorithm); \
  141.   NS_IMETHOD InitWithString(const nsACString & aAlgorithm); \
  142.   NS_IMETHOD Update(const PRUint8 *aData, PRUint32 aLen); \
  143.   NS_IMETHOD UpdateFromStream(nsIInputStream *aStream, PRUint32 aLen); \
  144.   NS_IMETHOD Finish(PRBool aASCII, nsACString & _retval); 
  145.  
  146. /* Use this macro to declare functions that forward the behavior of this interface to another object. */
  147. #define NS_FORWARD_NSICRYPTOHASH(_to) \
  148.   NS_IMETHOD Init(PRUint32 aAlgorithm) { return _to Init(aAlgorithm); } \
  149.   NS_IMETHOD InitWithString(const nsACString & aAlgorithm) { return _to InitWithString(aAlgorithm); } \
  150.   NS_IMETHOD Update(const PRUint8 *aData, PRUint32 aLen) { return _to Update(aData, aLen); } \
  151.   NS_IMETHOD UpdateFromStream(nsIInputStream *aStream, PRUint32 aLen) { return _to UpdateFromStream(aStream, aLen); } \
  152.   NS_IMETHOD Finish(PRBool aASCII, nsACString & _retval) { return _to Finish(aASCII, _retval); } 
  153.  
  154. /* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
  155. #define NS_FORWARD_SAFE_NSICRYPTOHASH(_to) \
  156.   NS_IMETHOD Init(PRUint32 aAlgorithm) { return !_to ? NS_ERROR_NULL_POINTER : _to->Init(aAlgorithm); } \
  157.   NS_IMETHOD InitWithString(const nsACString & aAlgorithm) { return !_to ? NS_ERROR_NULL_POINTER : _to->InitWithString(aAlgorithm); } \
  158.   NS_IMETHOD Update(const PRUint8 *aData, PRUint32 aLen) { return !_to ? NS_ERROR_NULL_POINTER : _to->Update(aData, aLen); } \
  159.   NS_IMETHOD UpdateFromStream(nsIInputStream *aStream, PRUint32 aLen) { return !_to ? NS_ERROR_NULL_POINTER : _to->UpdateFromStream(aStream, aLen); } \
  160.   NS_IMETHOD Finish(PRBool aASCII, nsACString & _retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Finish(aASCII, _retval); } 
  161.  
  162. #if 0
  163. /* Use the code below as a template for the implementation class for this interface. */
  164.  
  165. /* Header file */
  166. class nsCryptoHash : public nsICryptoHash
  167. {
  168. public:
  169.   NS_DECL_ISUPPORTS
  170.   NS_DECL_NSICRYPTOHASH
  171.  
  172.   nsCryptoHash();
  173.  
  174. private:
  175.   ~nsCryptoHash();
  176.  
  177. protected:
  178.   /* additional members */
  179. };
  180.  
  181. /* Implementation file */
  182. NS_IMPL_ISUPPORTS1(nsCryptoHash, nsICryptoHash)
  183.  
  184. nsCryptoHash::nsCryptoHash()
  185. {
  186.   /* member initializers and constructor code */
  187. }
  188.  
  189. nsCryptoHash::~nsCryptoHash()
  190. {
  191.   /* destructor code */
  192. }
  193.  
  194. /* void init (in unsigned long aAlgorithm); */
  195. NS_IMETHODIMP nsCryptoHash::Init(PRUint32 aAlgorithm)
  196. {
  197.     return NS_ERROR_NOT_IMPLEMENTED;
  198. }
  199.  
  200. /* void initWithString (in ACString aAlgorithm); */
  201. NS_IMETHODIMP nsCryptoHash::InitWithString(const nsACString & aAlgorithm)
  202. {
  203.     return NS_ERROR_NOT_IMPLEMENTED;
  204. }
  205.  
  206. /* void update ([array, size_is (aLen), const] in octet aData, in unsigned long aLen); */
  207. NS_IMETHODIMP nsCryptoHash::Update(const PRUint8 *aData, PRUint32 aLen)
  208. {
  209.     return NS_ERROR_NOT_IMPLEMENTED;
  210. }
  211.  
  212. /* void updateFromStream (in nsIInputStream aStream, in unsigned long aLen); */
  213. NS_IMETHODIMP nsCryptoHash::UpdateFromStream(nsIInputStream *aStream, PRUint32 aLen)
  214. {
  215.     return NS_ERROR_NOT_IMPLEMENTED;
  216. }
  217.  
  218. /* ACString finish (in PRBool aASCII); */
  219. NS_IMETHODIMP nsCryptoHash::Finish(PRBool aASCII, nsACString & _retval)
  220. {
  221.     return NS_ERROR_NOT_IMPLEMENTED;
  222. }
  223.  
  224. /* End of implementation class template. */
  225. #endif
  226.  
  227.  
  228. #endif /* __gen_nsICryptoHash_h__ */
  229.